package com.dehui.traders.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.TextAppearanceSpan;
import android.widget.TextView;

import com.dehui.traders.R;
import com.dehui.traders.bean.TheBroaderBean;
import com.dehui.traders.ui.fragment.market.TheBroaderMarketFragment;
import com.dehui.traders.widgets.MyHScrollView;

import java.util.List;

/**
 * Created by hqq on 18.4.25.
 */

public class TheBroaderAdapter extends TableAdapter<TheBroaderBean>{

    private static final int Index_ZhangFu = 0;
    private static final int Index_ZhangDie = 1;
    private static final int Index_HuanShou = 2;
    private static final int Index_ZongShou = 3;
    private static final int Index_ZongE = 4;
    private static final int Index_LiangBi = 5;
    private static final int Index_ZhengFu = 6;
    private static final int Index_ZhangSu = 7;
    private static final int Index_5DayZhang = 8;
    private static final int Index_5DayHuan = 9;
    private static final int Index_YangBenLiang = 10;
    private static final int Index_YangBenJunJia = 11;
    private static final int Index_PingJunGuBen = 12;
    private static final int Index_ZongShiZhi = 13;
    private static final int Index_ZhanBi = 14;
    private static final int Index_JingTaiShiYingLv = 15;
    private Fragment fragment;

    public TheBroaderAdapter(Context context, List mDatas, Fragment fragment) {
        super(context, mDatas);
        this.fragment = fragment;
    }

    @Override
    public void setFragment(MyHScrollView scrollview) {
        scrollview.setFragemnt(fragment);
    }

    @Override
    public void setItemText(int position, TextView tv,TheBroaderBean item) {
        switch (position){
            case Index_ZhangFu:
                tv.setText(item.datas[1]);
                tv.setTextColor(Color.RED);
                break;
            case Index_ZhangDie:
                tv.setText(item.datas[2]);
                tv.setTextColor(Color.RED);
                break;
            case Index_HuanShou:
                tv.setText(item.datas[3]);
                tv.setTextColor(Color.YELLOW);
                break;
            case Index_ZongShou:
                tv.setText(item.datas[4]);
                tv.setTextColor(Color.YELLOW);
                break;
            case Index_ZongE:
                tv.setText(item.datas[5]);
                tv.setTextColor(Color.BLUE);
                break;
            case Index_LiangBi:
                tv.setText(item.datas[6]);
                tv.setTextColor(Color.YELLOW);
                break;
            case Index_ZhengFu:
                tv.setText(item.datas[7]);
                tv.setTextColor(Color.RED);
                break;
            case Index_ZhangSu:
                tv.setText(item.datas[8]);
                tv.setTextColor(Color.RED);
                break;
            case Index_5DayZhang:
                tv.setText(item.datas[9]);
                tv.setTextColor(Color.RED);
                break;
            case Index_5DayHuan:
                tv.setText(item.datas[10]);
                break;
            case Index_YangBenLiang:
                tv.setText(item.datas[11]);
                break;
            case Index_YangBenJunJia:
                tv.setText(item.datas[12]);
                break;
            case Index_PingJunGuBen:
                tv.setText(item.datas[13]);
                break;
            case Index_ZongShiZhi:
                tv.setText(item.datas[14]);
                break;
            case Index_ZhanBi:
                tv.setText(item.datas[15]);
                break;
            case Index_JingTaiShiYingLv:
                tv.setText(item.datas[16]);
                break;
        }

    }

    @Override
    public SpannableString setTv0(TheBroaderBean item) {
        String title = item.name + "\n" + item.code;
        SpannableString styledText = new SpannableString(title);
        styledText.setSpan(new TextAppearanceSpan(mContext, R.style.style_title_0), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledText.setSpan(new TextAppearanceSpan(mContext, R.style.style_title_1), 4, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return styledText;
    }

    @Override
    public String setTv1(TheBroaderBean item) {
        return item.datas[0];
    }

    @Override
    public int getL() {
        return 16;
    }


}
